home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_097 / shm / shm_cycle_time.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  4KB  |  143 lines

  1. /************************************************************************
  2.                          Cycle Time Requester                 1 August 87
  3. ************************************************************************/
  4. #include <exec/types.h>
  5. #include <intuition/intuition.h>
  6.  
  7. #include "shm_defines"
  8.  
  9. extern struct TextAttr Fnt;
  10.  
  11. /************************************************************************
  12.                          Cycle Time Definitions
  13. ************************************************************************/
  14. char cycle_time_str[4];
  15.  
  16. struct IntuiText cycle_time_val_txt =
  17.        {1, 3, JAM2, 10, 14, &Fnt, (UBYTE *)cycle_time_str, NL};
  18. struct IntuiText cycle_time_secs_txt =
  19.        {1, 0, JAM1, 52, 28, &Fnt, (UBYTE *)"Seconds per colour step", NL};
  20. struct IntuiText cycle_time_txt =
  21.        {1, 0, JAM1, 80, 4, &Fnt, (UBYTE *)"CYCLE TIME",
  22.        &cycle_time_secs_txt};
  23. struct IntuiText cycle_time_ok_txt =
  24.        {1, 0, JAM1, 2, 2, &Fnt, (UBYTE *)"OK", NL};
  25.  
  26.  
  27. struct Image cycle_time_ok_img = {0,0, 20,11, 1, NL, 0, 2, NL};
  28.  
  29. struct Image cycle_time_img;
  30. struct PropInfo cycle_time_prop;
  31.  
  32. struct Gadget cycle_time_gad =
  33. {
  34. NL,
  35. 6, 14, 210, 11,
  36. GADGHCOMP,
  37. GADGIMMEDIATE | RELVERIFY,
  38. PROPGADGET | REQGADGET,
  39. (APTR)&cycle_time_img, NL,
  40. &cycle_time_val_txt,
  41. NL,
  42. (APTR)&cycle_time_prop,
  43. 1, NL
  44. };
  45.  
  46. struct Gadget cycle_time_ok_gad =
  47. {
  48. &cycle_time_gad,
  49. 222, 14, 20, 11,
  50. GADGHBOX | GADGIMAGE,
  51. RELVERIFY | ENDGADGET,
  52. BOOLGADGET | REQGADGET,
  53. (APTR)&cycle_time_ok_img, NL,
  54. &cycle_time_ok_txt,
  55. NL, NL, 2, NL
  56. };
  57.  
  58. struct Requester cycle_time_req;
  59.  
  60. #define SPX 250
  61. #define SPY 40
  62.  
  63. SHORT cycle_time_border_coords[] =
  64. {0,0, SPX-1,0, SPX-1,SPY-1, 0,SPY-1, 0,0};
  65.  
  66. struct Border cycle_time_border =
  67. {
  68. 0,0,
  69. 1,0, JAM1,
  70. 5, &cycle_time_border_coords[0],
  71. NL
  72. };
  73.  
  74. /************************************************************************
  75.                           Cycle Time Function
  76. ************************************************************************/
  77. int cycle_time(cW,ticks)
  78. struct Window *cW;
  79. int ticks;
  80. {
  81. struct IntuiMessage *message;
  82. struct Gadget *gad;
  83. BOOL loop;
  84. int class,ticks_c;
  85.  
  86. ModifyIDCMP(cW,GADGETUP | GADGETDOWN | REQCLEAR | MOUSEMOVE);
  87.  
  88.                 /* Remember to set REPORTMOUSE flag in window structure
  89.                                                for MOUSEMOVE to work */
  90. cycle_time_prop.Flags = FREEHORIZ | AUTOKNOB;
  91. cycle_time_prop.HorizBody = 0x1000;
  92. sprintf(cycle_time_str,"%3.1f\0",ticks/10.0);
  93.  
  94. InitRequester(&cycle_time_req);
  95. cycle_time_req.LeftEdge = 250;
  96. cycle_time_req.TopEdge = 25;
  97. cycle_time_req.Width = SPX;
  98. cycle_time_req.Height = SPY;
  99. cycle_time_req.ReqGadget = &cycle_time_ok_gad;
  100. cycle_time_req.ReqText = &cycle_time_txt;
  101. cycle_time_req.BackFill = 3;
  102. cycle_time_req.ReqBorder = &cycle_time_border;
  103. Request(&cycle_time_req,cW);
  104.  
  105. cycle_time_prop.HorizPot = (int)(65535*ticks)/10;
  106. RefreshGadgets(&cycle_time_ok_gad,cW,NL);
  107.  
  108. loop = TRUE;
  109.  
  110. while (loop)
  111.       {
  112.       Wait(1 << cW->UserPort->mp_SigBit); /* Be good and go to sleep till
  113.                                              Intuition sends a message */
  114.  
  115.       while (message = (struct IntuiMessage *) GetMsg(cW->UserPort))
  116.          {
  117.          class = message->Class;   /* Process all outstanding Messages */
  118.          ReplyMsg(message);
  119.          if (class == REQCLEAR) loop = FALSE;           /* OK selected */
  120.          if (class == GADGETDOWN)
  121.             gad = (struct Gadget *) message->IAddress;
  122.          }
  123.  
  124.          /* MOUSEMOVE events are not acknowledged specifically, but by
  125.             generating a message cause the following code to update the
  126.             slider */
  127.  
  128.       if (gad->GadgetID == 1)
  129.          {
  130.          ticks_c = (cycle_time_prop.HorizPot*10)/65535;
  131.          if (ticks != ticks_c)
  132.             {
  133.             /* Update slider only if the value has changed */
  134.             ticks = ticks_c;
  135.             sprintf(cycle_time_str,"%3.1f\0",ticks/10.0);
  136.             RefreshGList(&cycle_time_gad,cW,&cycle_time_req,1);
  137.             }
  138.          }
  139.       }
  140. ModifyIDCMP(cW,MENUPICK | REQCLEAR | INTUITICKS);
  141. return(ticks);
  142. }
  143.